
package View;

import Control.ctrEntrada;
import Utilitaria.ValidaJTextField;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JDialog;

public class limEntrada extends javax.swing.JFrame {

    private final ctrEntrada control;
    ValidaJTextField objValida = new ValidaJTextField();

    public limEntrada(ctrEntrada objCtrLembrete) {
        control = objCtrLembrete;        
        initComponents();
        //Centraliza janela
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        int x = ge.getCenterPoint().x - (this.getWidth()/2);
        int y = ge.getCenterPoint().y - (this.getHeight()/2);
        setLocation(x, y);        
        //Setar foco na interface superior
        JDialog dia = new JDialog();
        dia.setModal(true);
        dia.setContentPane(getContentPane());
        dia.setBounds(this.getBounds());
        dia.setVisible(true);
        dia.setResizable(false);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        label_titulo = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        label_qtde = new javax.swing.JLabel();
        field_qtde = new javax.swing.JTextField();
        botao_salvar = new javax.swing.JButton();
        scrollPane_entrada = new javax.swing.JScrollPane();
        table_entrada = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        label_titulo.setFont(new java.awt.Font("Tahoma", 1, 22));
        label_titulo.setForeground(new java.awt.Color(255, 0, 0));
        label_titulo.setText("Entradas");

        label_qtde.setFont(new java.awt.Font("Tahoma", 0, 14));
        label_qtde.setText("Quantidade:");

        field_qtde.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        field_qtde.addKeyListener(new KeyAdapter(){  
            public void keyReleased(KeyEvent e){  
                if(!objValida.onlyNumbers(field_qtde, e.getKeyCode()))
                field_qtde.setText("");		 
            }  
        });

        botao_salvar.setFont(new java.awt.Font("Tahoma", 1, 14));
        botao_salvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/disquete.gif"))); // NOI18N
        botao_salvar.setText("Lançar");
        botao_salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botao_salvarActionPerformed(evt);
            }
        });

        table_entrada.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Data da entrada", "Qtde"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        scrollPane_entrada.setViewportView(table_entrada);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(label_qtde)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(field_qtde, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                        .addComponent(botao_salvar))
                    .addComponent(scrollPane_entrada, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botao_salvar)
                    .addComponent(label_qtde)
                    .addComponent(field_qtde, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrollPane_entrada, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addComponent(label_titulo, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_titulo)
                .addGap(5, 5, 5)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-335)/2, (screenSize.height-276)/2, 335, 276);
    }// </editor-fold>//GEN-END:initComponents

    private void botao_salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botao_salvarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_botao_salvarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botao_salvar;
    private javax.swing.JTextField field_qtde;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel label_qtde;
    private javax.swing.JLabel label_titulo;
    private javax.swing.JScrollPane scrollPane_entrada;
    private javax.swing.JTable table_entrada;
    // End of variables declaration//GEN-END:variables

}
